function J = costFunctionJ(X, y, theta)
% X is the "design matrix" contain our training examples.
% y is the class labels

m = size(X,1); % number of training examples
predictions = X*theta; % predictions of hypothesis on all m examples.
sqrErrors = (predictions-y).^2; % squared errors. we learn from 2-2 cost functinn
J = 1/(2*m)*sum(sqrErrors);

% usage
% x = [1 1;  1 2; 1 3]
% y = [1; 2; 3]
% theta = [0; 1]
% j = costFunctionJ(x,y,theta)